3T_ajax 로 이루어진 select, option 정보 가져오기 ( feat, 건강보험심사평가원 )

  • 시군구 읍면동 상세정보를 크롤링해서 => 하나의 DataFrame으로 만드는 실습
  • 먼저 해볼 것은 requests를 보내봐야 한다.

In [1]:
import requests
from bs4 import BeautifulSoup  #requests한 것을 parsiing하기 위해서

In [2]:
response = requests.get("http://www.hira.or.kr/re/diag/getDiagAmtList.do")

In [3]:
dom = BeautifulSoup(response.text, "html.parser")

In [4]:
dom.select_one("#sidoCd")


Out[4]:
<select class="srch-select" id="sidoCd" name="sidoCd" title="시/도 선택">
<option value="">시/도 선택</option>
</select>

In [5]:
select_element = dom.select_one("#sidoCd")

In [6]:
print(select_element)


<select class="srch-select" id="sidoCd" name="sidoCd" title="시/도 선택">
<option value="">시/도 선택</option>
</select>
  • 주소를 동적으로 ( ajax / javascript ) 를 이용해서 보내주는구나.
  • 다음에는? 네트워크를 확인한다. 동적이 아닐 수도 있으니까. 정적일수도 있으니까

In [8]:
response = requests.post("http://www.hira.or.kr/rd/hosp/selectSidoListAjax.do")

In [9]:
response.text


Out[9]:
'{"failed":false,"data":[{"commCd":"11","commCdDsc":"","commCdNm":"서울","commCdParent":"","commCdTxt":"","commTyCd":"","firstIndex":1,"hiSno":"","lastIndex":1,"list":[],"lv":0,"pageIndex":1,"pageSize":10,"pageUnit":10,"payCrtrUrlPth":"","payXpnsUrlPth":"","pgmid":"","recordCountPerPage":10,"rowNo":0,"searchCnd":"","searchWrd":"","sgguCd":"","sgguCdNm":"","sidoCd":"","sidoCdNm":"","sno":"","sortOrdr":"","sortRk":""},{"commCd":"21","commCdDsc":"","commCdNm":"부산","commCdParent":"","commCdTxt":"","commTyCd":"","firstIndex":1,"hiSno":"","lastIndex":1,"list":[],"lv":0,"pageIndex":1,"pageSize":10,"pageUnit":10,"payCrtrUrlPth":"","payXpnsUrlPth":"","pgmid":"","recordCountPerPage":10,"rowNo":0,"searchCnd":"","searchWrd":"","sgguCd":"","sgguCdNm":"","sidoCd":"","sidoCdNm":"","sno":"","sortOrdr":"","sortRk":""},{"commCd":"22","commCdDsc":"","commCdNm":"인천","commCdParent":"","commCdTxt":"","commTyCd":"","firstIndex":1,"hiSno":"","lastIndex":1,"list":[],"lv":0,"pageIndex":1,"pageSize":10,"pageUnit":10,"payCrtrUrlPth":"","payXpnsUrlPth":"","pgmid":"","recordCountPerPage":10,"rowNo":0,"searchCnd":"","searchWrd":"","sgguCd":"","sgguCdNm":"","sidoCd":"","sidoCdNm":"","sno":"","sortOrdr":"","sortRk":""},{"commCd":"23","commCdDsc":"","commCdNm":"대구","commCdParent":"","commCdTxt":"","commTyCd":"","firstIndex":1,"hiSno":"","lastIndex":1,"list":[],"lv":0,"pageIndex":1,"pageSize":10,"pageUnit":10,"payCrtrUrlPth":"","payXpnsUrlPth":"","pgmid":"","recordCountPerPage":10,"rowNo":0,"searchCnd":"","searchWrd":"","sgguCd":"","sgguCdNm":"","sidoCd":"","sidoCdNm":"","sno":"","sortOrdr":"","sortRk":""},{"commCd":"24","commCdDsc":"","commCdNm":"광주","commCdParent":"","commCdTxt":"","commTyCd":"","firstIndex":1,"hiSno":"","lastIndex":1,"list":[],"lv":0,"pageIndex":1,"pageSize":10,"pageUnit":10,"payCrtrUrlPth":"","payXpnsUrlPth":"","pgmid":"","recordCountPerPage":10,"rowNo":0,"searchCnd":"","searchWrd":"","sgguCd":"","sgguCdNm":"","sidoCd":"","sidoCdNm":"","sno":"","sortOrdr":"","sortRk":""},{"commCd":"25","commCdDsc":"","commCdNm":"대전","commCdParent":"","commCdTxt":"","commTyCd":"","firstIndex":1,"hiSno":"","lastIndex":1,"list":[],"lv":0,"pageIndex":1,"pageSize":10,"pageUnit":10,"payCrtrUrlPth":"","payXpnsUrlPth":"","pgmid":"","recordCountPerPage":10,"rowNo":0,"searchCnd":"","searchWrd":"","sgguCd":"","sgguCdNm":"","sidoCd":"","sidoCdNm":"","sno":"","sortOrdr":"","sortRk":""},{"commCd":"26","commCdDsc":"","commCdNm":"울산","commCdParent":"","commCdTxt":"","commTyCd":"","firstIndex":1,"hiSno":"","lastIndex":1,"list":[],"lv":0,"pageIndex":1,"pageSize":10,"pageUnit":10,"payCrtrUrlPth":"","payXpnsUrlPth":"","pgmid":"","recordCountPerPage":10,"rowNo":0,"searchCnd":"","searchWrd":"","sgguCd":"","sgguCdNm":"","sidoCd":"","sidoCdNm":"","sno":"","sortOrdr":"","sortRk":""},{"commCd":"31","commCdDsc":"","commCdNm":"경기","commCdParent":"","commCdTxt":"","commTyCd":"","firstIndex":1,"hiSno":"","lastIndex":1,"list":[],"lv":0,"pageIndex":1,"pageSize":10,"pageUnit":10,"payCrtrUrlPth":"","payXpnsUrlPth":"","pgmid":"","recordCountPerPage":10,"rowNo":0,"searchCnd":"","searchWrd":"","sgguCd":"","sgguCdNm":"","sidoCd":"","sidoCdNm":"","sno":"","sortOrdr":"","sortRk":""},{"commCd":"32","commCdDsc":"","commCdNm":"강원","commCdParent":"","commCdTxt":"","commTyCd":"","firstIndex":1,"hiSno":"","lastIndex":1,"list":[],"lv":0,"pageIndex":1,"pageSize":10,"pageUnit":10,"payCrtrUrlPth":"","payXpnsUrlPth":"","pgmid":"","recordCountPerPage":10,"rowNo":0,"searchCnd":"","searchWrd":"","sgguCd":"","sgguCdNm":"","sidoCd":"","sidoCdNm":"","sno":"","sortOrdr":"","sortRk":""},{"commCd":"33","commCdDsc":"","commCdNm":"충북","commCdParent":"","commCdTxt":"","commTyCd":"","firstIndex":1,"hiSno":"","lastIndex":1,"list":[],"lv":0,"pageIndex":1,"pageSize":10,"pageUnit":10,"payCrtrUrlPth":"","payXpnsUrlPth":"","pgmid":"","recordCountPerPage":10,"rowNo":0,"searchCnd":"","searchWrd":"","sgguCd":"","sgguCdNm":"","sidoCd":"","sidoCdNm":"","sno":"","sortOrdr":"","sortRk":""},{"commCd":"34","commCdDsc":"","commCdNm":"충남","commCdParent":"","commCdTxt":"","commTyCd":"","firstIndex":1,"hiSno":"","lastIndex":1,"list":[],"lv":0,"pageIndex":1,"pageSize":10,"pageUnit":10,"payCrtrUrlPth":"","payXpnsUrlPth":"","pgmid":"","recordCountPerPage":10,"rowNo":0,"searchCnd":"","searchWrd":"","sgguCd":"","sgguCdNm":"","sidoCd":"","sidoCdNm":"","sno":"","sortOrdr":"","sortRk":""},{"commCd":"35","commCdDsc":"","commCdNm":"전북","commCdParent":"","commCdTxt":"","commTyCd":"","firstIndex":1,"hiSno":"","lastIndex":1,"list":[],"lv":0,"pageIndex":1,"pageSize":10,"pageUnit":10,"payCrtrUrlPth":"","payXpnsUrlPth":"","pgmid":"","recordCountPerPage":10,"rowNo":0,"searchCnd":"","searchWrd":"","sgguCd":"","sgguCdNm":"","sidoCd":"","sidoCdNm":"","sno":"","sortOrdr":"","sortRk":""},{"commCd":"36","commCdDsc":"","commCdNm":"전남","commCdParent":"","commCdTxt":"","commTyCd":"","firstIndex":1,"hiSno":"","lastIndex":1,"list":[],"lv":0,"pageIndex":1,"pageSize":10,"pageUnit":10,"payCrtrUrlPth":"","payXpnsUrlPth":"","pgmid":"","recordCountPerPage":10,"rowNo":0,"searchCnd":"","searchWrd":"","sgguCd":"","sgguCdNm":"","sidoCd":"","sidoCdNm":"","sno":"","sortOrdr":"","sortRk":""},{"commCd":"37","commCdDsc":"","commCdNm":"경북","commCdParent":"","commCdTxt":"","commTyCd":"","firstIndex":1,"hiSno":"","lastIndex":1,"list":[],"lv":0,"pageIndex":1,"pageSize":10,"pageUnit":10,"payCrtrUrlPth":"","payXpnsUrlPth":"","pgmid":"","recordCountPerPage":10,"rowNo":0,"searchCnd":"","searchWrd":"","sgguCd":"","sgguCdNm":"","sidoCd":"","sidoCdNm":"","sno":"","sortOrdr":"","sortRk":""},{"commCd":"38","commCdDsc":"","commCdNm":"경남","commCdParent":"","commCdTxt":"","commTyCd":"","firstIndex":1,"hiSno":"","lastIndex":1,"list":[],"lv":0,"pageIndex":1,"pageSize":10,"pageUnit":10,"payCrtrUrlPth":"","payXpnsUrlPth":"","pgmid":"","recordCountPerPage":10,"rowNo":0,"searchCnd":"","searchWrd":"","sgguCd":"","sgguCdNm":"","sidoCd":"","sidoCdNm":"","sno":"","sortOrdr":"","sortRk":""},{"commCd":"39","commCdDsc":"","commCdNm":"제주","commCdParent":"","commCdTxt":"","commTyCd":"","firstIndex":1,"hiSno":"","lastIndex":1,"list":[],"lv":0,"pageIndex":1,"pageSize":10,"pageUnit":10,"payCrtrUrlPth":"","payXpnsUrlPth":"","pgmid":"","recordCountPerPage":10,"rowNo":0,"searchCnd":"","searchWrd":"","sgguCd":"","sgguCdNm":"","sidoCd":"","sidoCdNm":"","sno":"","sortOrdr":"","sortRk":""},{"commCd":"41","commCdDsc":"","commCdNm":"세종","commCdParent":"","commCdTxt":"","commTyCd":"","firstIndex":1,"hiSno":"","lastIndex":1,"list":[],"lv":0,"pageIndex":1,"pageSize":10,"pageUnit":10,"payCrtrUrlPth":"","payXpnsUrlPth":"","pgmid":"","recordCountPerPage":10,"rowNo":0,"searchCnd":"","searchWrd":"","sgguCd":"","sgguCdNm":"","sidoCd":"","sidoCdNm":"","sno":"","sortOrdr":"","sortRk":""}]}'
  • json => dict

In [10]:
import json

In [11]:
json.loads(response.text)   #str => dict


Out[11]:
{'data': [{'commCd': '11',
   'commCdDsc': '',
   'commCdNm': '서울',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '21',
   'commCdDsc': '',
   'commCdNm': '부산',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '22',
   'commCdDsc': '',
   'commCdNm': '인천',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '23',
   'commCdDsc': '',
   'commCdNm': '대구',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '24',
   'commCdDsc': '',
   'commCdNm': '광주',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '25',
   'commCdDsc': '',
   'commCdNm': '대전',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '26',
   'commCdDsc': '',
   'commCdNm': '울산',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '31',
   'commCdDsc': '',
   'commCdNm': '경기',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '32',
   'commCdDsc': '',
   'commCdNm': '강원',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '33',
   'commCdDsc': '',
   'commCdNm': '충북',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '34',
   'commCdDsc': '',
   'commCdNm': '충남',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '35',
   'commCdDsc': '',
   'commCdNm': '전북',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '36',
   'commCdDsc': '',
   'commCdNm': '전남',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '37',
   'commCdDsc': '',
   'commCdNm': '경북',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '38',
   'commCdDsc': '',
   'commCdNm': '경남',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '39',
   'commCdDsc': '',
   'commCdNm': '제주',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '41',
   'commCdDsc': '',
   'commCdNm': '세종',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''}],
 'failed': False}

In [12]:
response.json()   #위에랑 동일하지만 더 쉽게 쓸 수 있다.


Out[12]:
{'data': [{'commCd': '11',
   'commCdDsc': '',
   'commCdNm': '서울',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '21',
   'commCdDsc': '',
   'commCdNm': '부산',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '22',
   'commCdDsc': '',
   'commCdNm': '인천',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '23',
   'commCdDsc': '',
   'commCdNm': '대구',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '24',
   'commCdDsc': '',
   'commCdNm': '광주',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '25',
   'commCdDsc': '',
   'commCdNm': '대전',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '26',
   'commCdDsc': '',
   'commCdNm': '울산',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '31',
   'commCdDsc': '',
   'commCdNm': '경기',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '32',
   'commCdDsc': '',
   'commCdNm': '강원',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '33',
   'commCdDsc': '',
   'commCdNm': '충북',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '34',
   'commCdDsc': '',
   'commCdNm': '충남',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '35',
   'commCdDsc': '',
   'commCdNm': '전북',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '36',
   'commCdDsc': '',
   'commCdNm': '전남',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '37',
   'commCdDsc': '',
   'commCdNm': '경북',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '38',
   'commCdDsc': '',
   'commCdNm': '경남',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '39',
   'commCdDsc': '',
   'commCdNm': '제주',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''},
  {'commCd': '41',
   'commCdDsc': '',
   'commCdNm': '세종',
   'commCdParent': '',
   'commCdTxt': '',
   'commTyCd': '',
   'firstIndex': 1,
   'hiSno': '',
   'lastIndex': 1,
   'list': [],
   'lv': 0,
   'pageIndex': 1,
   'pageSize': 10,
   'pageUnit': 10,
   'payCrtrUrlPth': '',
   'payXpnsUrlPth': '',
   'pgmid': '',
   'recordCountPerPage': 10,
   'rowNo': 0,
   'searchCnd': '',
   'searchWrd': '',
   'sgguCd': '',
   'sgguCdNm': '',
   'sidoCd': '',
   'sidoCdNm': '',
   'sno': '',
   'sortOrdr': '',
   'sortRk': ''}],
 'failed': False}

In [13]:
data = response.json()
  • 만약 네트워크에 정보가 잡히지 않으면?
  • javascipt로 네트워크 요청이 아니라 그냥 쌩으로 써준 것이다.
    • 내부에 이미 정보가 있다.
    • 그래서 일일이 찾아봐야 하는 번거로움
  • 대부분 동적으로 API 받는 형태로 되어 있다.
  • 로그인이 필요하다고 했을 때 selenium 으로 쓰면 된다.

In [14]:
data.get("data")[0]


Out[14]:
{'commCd': '11',
 'commCdDsc': '',
 'commCdNm': '서울',
 'commCdParent': '',
 'commCdTxt': '',
 'commTyCd': '',
 'firstIndex': 1,
 'hiSno': '',
 'lastIndex': 1,
 'list': [],
 'lv': 0,
 'pageIndex': 1,
 'pageSize': 10,
 'pageUnit': 10,
 'payCrtrUrlPth': '',
 'payXpnsUrlPth': '',
 'pgmid': '',
 'recordCountPerPage': 10,
 'rowNo': 0,
 'searchCnd': '',
 'searchWrd': '',
 'sgguCd': '',
 'sgguCdNm': '',
 'sidoCd': '',
 'sidoCdNm': '',
 'sno': '',
 'sortOrdr': '',
 'sortRk': ''}

In [15]:
df = pd.DataFrame(data.get("data"))

In [16]:
df


Out[16]:
commCd commCdDsc commCdNm commCdParent commCdTxt commTyCd firstIndex hiSno lastIndex list ... rowNo searchCnd searchWrd sgguCd sgguCdNm sidoCd sidoCdNm sno sortOrdr sortRk
0 11 서울 1 1 [] ... 0
1 21 부산 1 1 [] ... 0
2 22 인천 1 1 [] ... 0
3 23 대구 1 1 [] ... 0
4 24 광주 1 1 [] ... 0
5 25 대전 1 1 [] ... 0
6 26 울산 1 1 [] ... 0
7 31 경기 1 1 [] ... 0
8 32 강원 1 1 [] ... 0
9 33 충북 1 1 [] ... 0
10 34 충남 1 1 [] ... 0
11 35 전북 1 1 [] ... 0
12 36 전남 1 1 [] ... 0
13 37 경북 1 1 [] ... 0
14 38 경남 1 1 [] ... 0
15 39 제주 1 1 [] ... 0
16 41 세종 1 1 [] ... 0

17 rows × 28 columns


In [23]:
data = {
    "sidoCd": 11
}
response = requests.post("http://www.hira.or.kr/rd/hosp/selectSgguListAjax.do", data=data)

In [26]:
data = response.json()

In [27]:
city_df = pd.DataFrame(data.get("data"))

In [28]:
city_df


Out[28]:
commCd commCdDsc commCdNm commCdParent commCdTxt commTyCd firstIndex hiSno lastIndex list ... rowNo searchCnd searchWrd sgguCd sgguCdNm sidoCd sidoCdNm sno sortOrdr sortRk
0 110001 강남구 1 1 [] ... 0
1 110002 강동구 1 1 [] ... 0
2 110024 강북구 1 1 [] ... 0
3 110003 강서구 1 1 [] ... 0
4 110004 관악구 1 1 [] ... 0
5 110023 광진구 1 1 [] ... 0
6 110005 구로구 1 1 [] ... 0
7 110025 금천구 1 1 [] ... 0
8 110022 노원구 1 1 [] ... 0
9 110006 도봉구 1 1 [] ... 0
10 110007 동대문구 1 1 [] ... 0
11 110008 동작구 1 1 [] ... 0
12 110009 마포구 1 1 [] ... 0
13 110010 서대문구 1 1 [] ... 0
14 110021 서초구 1 1 [] ... 0
15 110011 성동구 1 1 [] ... 0
16 110012 성북구 1 1 [] ... 0
17 110018 송파구 1 1 [] ... 0
18 110020 양천구 1 1 [] ... 0
19 110013 영등포구 1 1 [] ... 0
20 110014 용산구 1 1 [] ... 0
21 110015 은평구 1 1 [] ... 0
22 110016 종로구 1 1 [] ... 0
23 110017 중구 1 1 [] ... 0
24 110019 중랑구 1 1 [] ... 0

25 rows × 28 columns


In [29]:
data = {
    "sidoCdNm": "서울",
    "sgguCdNm": "강남구",   #우리가 별도로 urlencoded를 할 필요가 없다.
}

response = requests.post("http://www.hira.or.kr/rd/hosp/selectDoroListAjax.do", data=data)

In [31]:
data = response.json()

doro_df = pd.DataFrame(data.get('data'))
doro_df


Out[31]:
commCd commCdDsc commCdNm commCdParent commCdTxt commTyCd firstIndex hiSno lastIndex list ... rowNo searchCnd searchWrd sgguCd sgguCdNm sidoCd sidoCdNm sno sortOrdr sortRk
0 강남대로 1 1 [] ... 0
1 개포로 1 1 [] ... 0
2 광평로 1 1 [] ... 0
3 남부순환로 1 1 [] ... 0
4 논현로 1 1 [] ... 0
5 도곡로 1 1 [] ... 0
6 도산대로 1 1 [] ... 0
7 밤고개로 1 1 [] ... 0
8 봉은사로 1 1 [] ... 0
9 삼성로 1 1 [] ... 0
10 선릉로 1 1 [] ... 0
11 압구정로 1 1 [] ... 0
12 양재대로 1 1 [] ... 0
13 언주로 1 1 [] ... 0
14 역삼로 1 1 [] ... 0
15 영동대로 1 1 [] ... 0
16 일원로 1 1 [] ... 0
17 테헤란로 1 1 [] ... 0
18 학동로 1 1 [] ... 0
19 헌릉로 1 1 [] ... 0

20 rows × 28 columns


In [32]:
# 도로명 주소 => DF
# 동명 => DF

pd.DataFrame(columns=["State", "City", "Town"])


Out[32]:
State City Town

In [33]:
# 서울 => 강남구.csv, 중구.csv. ....
# 부산 => ...

# 어떤 방법이든 상관 X

In [34]:
# (1) 특정 조건에 맞는 데이터를 뽑아내는 방법
# (2) df for 문 돌리는 방법 ( enumerate )

In [36]:
response = requests.get("https://api.zigbang.com/v1/items?detail=true&item_ids=4620292&item_ids=4366382&item_ids=4566963&item_ids=4585208&item_ids=4560308&item_ids=4552724&item_ids=4344484&item_ids=4612042&item_ids=4574810&item_ids=4588687&item_ids=4387287&item_ids=4538842&item_ids=4557985&item_ids=4579464&item_ids=4607349&item_ids=4603203&item_ids=4341393&item_ids=4575315&item_ids=4350877&item_ids=4538375&item_ids=4616443&item_ids=4281504&item_ids=4556024&item_ids=4550034&item_ids=4512172&item_ids=4507118&item_ids=4606156&item_ids=4457169&item_ids=4526327&item_ids=4407071&item_ids=4582264&item_ids=4607937&item_ids=4395275&item_ids=4568603&item_ids=4569329&item_ids=4564865&item_ids=4551098&item_ids=4617261&item_ids=4536918&item_ids=4614718&item_ids=4614198&item_ids=4610604&item_ids=4578711&item_ids=4593621&item_ids=4612621&item_ids=4518874&item_ids=4533169&item_ids=4409063&item_ids=4617602&item_ids=4477945&item_ids=4249606&item_ids=4560223&item_ids=4570020&item_ids=4517907&item_ids=4530774&item_ids=4525210&item_ids=4596138&item_ids=4588994&item_ids=4612357&item_ids=4411862")

In [37]:
data = response.json()

In [38]:
df = pd.DataFrame(data.get('items'))

In [39]:
df


Out[39]:
header header_height item title
0 False 0 {'building_type': '다세대건물', 'address1': '서울시 관악... 서울시 관악구 신림동
1 False 0 {'building_type': '다세대건물', 'address1': '서울시 관악... 서울시 관악구 봉천동
2 False 0 {'building_type': '다세대건물', 'address1': '서울시 관악... 서울시 관악구 신림동
3 False 0 {'building_type': '다세대건물', 'address1': '서울시 관악... 서울시 관악구 신림동
4 False 0 {'building_type': '다세대건물', 'address1': '서울시 관악... 서울시 관악구 신림동
5 False 0 {'building_type': '다세대건물', 'address1': '서울시 관악... 서울시 관악구 봉천동
6 False 0 {'building_type': '다세대건물', 'address1': '서울시 관악... 서울시 관악구 신림동
7 False 0 {'building_type': '다세대건물', 'address1': '서울시 관악... 서울시 관악구 봉천동
8 False 0 {'building_type': '다세대건물', 'address1': '서울시 관악... 서울시 관악구 신림동
9 False 0 {'building_type': '다세대건물', 'address1': '서울시 관악... 서울시 관악구 신림동
10 False 0 {'building_type': '오피스텔·도생', 'address1': '서울시 ... 서울시 관악구 봉천동
11 False 0 {'building_type': '다세대건물', 'address1': '서울시 구로... 서울시 구로구 구로3동
12 False 0 {'building_type': '오피스텔·도생', 'address1': '서울시 ... 서울시 금천구 독산동
13 False 0 {'building_type': '다세대건물', 'address1': '서울시 동작... 서울시 동작구 상도동
14 False 0 {'building_type': '다세대건물', 'address1': '서울시 관악... 서울시 관악구 봉천동
15 False 0 {'building_type': '다세대건물', 'address1': '서울시 관악... 서울시 관악구 봉천동
16 False 0 {'building_type': '다세대건물', 'address1': '서울시 동작... 서울시 동작구 신대방1동
17 False 0 {'building_type': '다세대건물', 'address1': '서울시 관악... 서울시 관악구 신림동
18 False 0 {'building_type': '다세대건물', 'address1': '서울시 관악... 서울시 관악구 신림동
19 False 0 {'building_type': '다세대건물', 'address1': '서울시 관악... 서울시 관악구 신림동

In [40]:
zigzig = [
    item.get('item')
    for item
    in data.get('items')
]

In [41]:
df = pd.DataFrame(zigzig)
df


Out[41]:
address1 address2 address3 agent_address1 agent_comment agent_email agent_local1 agent_local2 agent_mobile agent_name ... title updated_at user_email user_has_no_penalty user_has_penalty user_mobile user_name user_no user_phone view_count
0 서울시 관악구 신림동 95-81 None 서울특별시 관악구 관악로15길 23 (봉천동) sky_rendi@naver.com 서울시 관악구 0507-1280-7420 부동산매거진공인중개사(김기영) ... ☎ 신축급 분리형원룸, 보증금 조정가, 날짜협의, 주인거주 3개월 전 lasolitudine@nate.com True False 0507-1280-8188 중개보조원(오종섭) 814905 0507-1280-8188 201
1 서울시 관악구 봉천동 890-8 None 서울특별시 관악구 신림동 11-19 dbip@naver.com 서울시 관악구 0507-1281-8213 시티부동산(이영금) ... 서울대입구역에서 가장큰 신축빌라 전세 3개월 전 goldsong874@naver.com True False 0507-1281-3867 중개보조원(오금송) 362268 0507-1281-3867 622
2 서울시 관악구 신림동 1417-31 None 서울특별시 관악구 신림로 68길 29(신림동) goodhouse427@naver.com 서울시 관악구 0507-1280-3054 365공인중개사(유미선) ... ★가격대비 대만족 원룸 채광짱 구조짱~ 3개월 전 goodhouse427@naver.com True False 0507-1280-3054 대표공인중개사(유미선) 247417 0507-1280-3054 250
3 서울시 관악구 신림동 1661 None 서울특별시 관악구 조원로2길 55 (신림동) golf0821@hanmail.net 서울시 관악구 010-7795-5979 상가점포114공인중개사(조용수) ... 넓~~은 투룸,,전세 2억 있습니다..구로디지털단지역 도보4분 3개월 전 golf0821@hanmail.net True False 010-7795-5979 대표공인중개사(조용수) 1065782 010-7795-5979 648
4 서울시 관악구 신림동 1417-23 None 서울특별시 관악구 신림동 1461-3 1층 pterpan2010@naver.com 서울시 관악구 0507-1281-1963 피터팬공인중개사(김정웅) ... ♥정남향♥탁트인시야♥분리형♥역세도보5분♥FULL옵션♥평지♥ 2개월 전 pterpan2010@naver.com True False 0507-1281-1963 대표공인중개사(김정웅) 847301 0507-1281-1963 614
5 서울시 관악구 봉천동 933-26 None 서울특별시 관악구 봉천동 933-20 nadoyo2@naver.com 서울시 관악구 0507-1281-1580 21세기공인중개사(강병국) ... 역세권 엄청싸게나온 풀옵션 지상 방1 3개월 전 boktj1002@naver.com True False 0507-1281-0303 중개보조원(복소경) 1434787 0507-1281-0303 389
6 서울시 관악구 신림동 499-29 None 서울특별시 관악구 신림동 1464-42 taeyang0620@naver.com 서울시 관악구 0507-1280-8705 태양공인중개사(문형숙) ... 신축첫입주☝CCTV철통보안⚠완전풀옵션!주차가능✔초역세권✏허위타파✌ 3개월 전 taeyang0620@naver.com True False 0507-1280-8705 대표공인중개사(문형숙) 1000821 0507-1280-8705 2
7 서울시 관악구 봉천동 1512-14 None 서울특별시 관악구 봉천동 875-1 관악캠퍼스타워 1층 8714985.j00ny1@naver.com 서울시 관악구 0507-1280-7389 타워공인중개사(장정수) ... 신축 채광좋은 원룸입니다 3개월 전 joony24@naver.com True False 0507-1280-7645 중개보조원(한동아) 28054 0507-1280-7645 439
8 서울시 관악구 신림동 549-3 None 서울특별시 관악구 신림동 549-3 media2000@naver.com 서울시 관악구 0507-1280-2542 에버부동산중개사(류애형) ... 귀한 전세 ★ 깔끔하고 살기 좋은곳 ★ 3개월 전 mys287@hanmail.net True False 0507-1280-2798 중개보조원(심미경) 247414 0507-1280-2798 429
9 서울시 관악구 신림동 1629-54 None 서울특별시 관악구 신원로 26 (신림동) choyu00@nate.com 서울시 관악구 0507-1280-8154 발품공인중개사(조종현) ... 깔끄미 신축2룸 소개합니다^^ 3개월 전 choyu00@nate.com True False 0507-1280-8410 중개보조원(소재현) 14007 0507-1280-8410 314
10 서울시 관악구 봉천동 861-7 None 서울특별시 관악구 봉천로 472 102(봉천동) coresi@naver.com 서울시 관악구 0507-1280-1535 코업공인중개사(황경숙) ... ▶☀❤ 고보증 월세 초역세권 호텔식 풀옵션 ▶☀❤ 2개월 전 coresi@naver.com True False 0507-1280-1535 대표공인중개사(황경숙) 932772 0507-1280-1535 1021
11 서울시 구로구 구로3동 1126-36 None 서울특별시 구로구 구로동 1126-37 chk13189@naver.com 서울시 구로구 0507-1280-0488 수공인중개사(조혜경) ... ☀이벤트☀ 건물주가 미쳤어요 ~_~ 클릭!클릭! 3개월 전 chk13189@naver.com True False 0507-1280-0488 대표공인중개사(조혜경) 128135 0507-1280-0488 315
12 서울시 금천구 독산동 143-1 None 서울특별시 금천구 남부순환로 1314, 102호 (독산동) kmyoon428@naver.com 서울시 금천구 0507-1280-3833 아네스트공인중개사(윤경민) ... 구디역 전세 복층 - 전세자금대출 / 전입 / 확정일자 가능 3개월 전 kmyoon428@naver.com True False 0507-1280-3833 대표공인중개사(윤경민) 676702 0507-1280-3833 2257
13 서울시 동작구 상도동 303-13 None 서울특별시 동작구 보라매로11길 3, 1층 yohousing@naver.com 서울시 동작구 0507-1281-1050 스타공인중개사(한상호) ... oOo깨끗한데 젤~~~싸요!!oOo 2개월 전 taegi76@naver.com True False 0507-1281-0028 중개보조원(김진택) 1399779 0507-1281-0028 235
14 서울시 관악구 봉천동 1605-25 None 서울특별시 관악구 봉천동 1598-23 1층 minho012@naver.com 서울시 관악구 0108-5536-4491 샛별공인중개사(이덕순) ... A급 반지하 3개월 전 minho012@naver.com True False 0108-5536-4491 대표공인중개사(이덕순) 1086355 0108-5536-4491 190
15 서울시 관악구 봉천동 62-27 None 서울특별시 관악구 봉천동 858-9 sms690506@naver.com 서울시 관악구 0507-1280-7139 남부공인중개사(송무석) ... 신축형 전세9천으로 비가와도 오셔야 할듯 3개월 전 e7301@korea.com True False 0507-1280-7395 이은순 80394 0507-1280-7395 492
16 서울시 동작구 신대방1동 686-29 None 서울특별시 동작구 신대방1동 694 somang9079@naver.com 서울시 동작구 010-5248-9079 인기공인중개사(최경숙) ... 분리형원룸으로 채광이 아주좋아요 3개월 전 somang9079@naver.com True False 010-5248-9079 대표공인중개사(최경숙) 950535 010-5248-9079 567
17 서울시 관악구 신림동 1463-60 None 서울특별시 관악구 신림동 1433-127 wed1730@nate.com 서울시 관악구 010-5919-1996 하나공인중개사(김옥철) ... ★ 분리형/ 채광/ 반전세/ 위치 모두 GooD!! ★ 2개월 전 01088490350@hanmail.net True False 010-8849-0350 중개보조원(홍나래) 115692 010-8849-0350 534
18 서울시 관악구 신림동 신림동482-18 None 서울특별시 관악구 신림동 513-23 housebank0320@naver.com 서울시 관악구 0507-1280-6650 부동산뱅크공인중개사(이찬숙) ... ♠♠투룸, 깨끗한 집입니다♠♠ 2개월 전 housebank0320@naver.com True False 0507-1280-6650 대표공인중개사(이찬숙) 742205 0507-1280-6650 225
19 서울시 관악구 신림동 1419-10 None 서울특별시 관악구 신림동1435-2 kb1001@naver.com 서울시 관악구 0507-1280-2011 부동산마트공인중개사(김천완) ... 신림역도보5분 신혼부부에 안성맞춤인 신축급 투룸 전세! 3개월 전 kb1001@naver.com True False 0507-1280-2011 대표공인중개사(김천완) 14899 0507-1280-2011 1167

20 rows × 73 columns


In [42]:
df.describe()


Out[42]:
deposit id images_count rent size size_contract user_no view_count
count 20.000000 2.000000e+01 20.000000 20.000000 20.000000 20.000000 2.000000e+01 20.000000
mean 6495.000000 4.500335e+06 10.150000 23.100000 8.225000 2.100000 6.095112e+05 545.550000
std 7884.259802 9.587814e+04 3.950683 21.358839 5.115701 4.689294 4.790956e+05 489.313964
min 300.000000 4.281504e+06 5.000000 0.000000 3.000000 0.000000 1.400700e+04 2.000000
25% 1000.000000 4.411162e+06 7.000000 0.000000 5.000000 0.000000 1.250242e+05 246.250000
50% 2250.000000 4.537646e+06 10.000000 32.000000 6.000000 0.000000 7.094535e+05 434.000000
75% 9250.000000 4.569051e+06 12.000000 36.250000 8.250000 0.000000 9.631065e+05 616.000000
max 30000.000000 4.616443e+06 19.000000 70.000000 23.000000 17.000000 1.434787e+06 2257.000000

In [43]:
len(df)


Out[43]:
20

In [44]:
df["deposit"]   #2000만원 이하이면서 월세 50만원 이하인 거 찾기


Out[44]:
0      5000
1     30000
2       300
3     18000
4      8000
5       300
6      2000
7      2500
8      5000
9      1000
10     2000
11      300
12    10000
13      500
14     1000
15     9000
16     2000
17     2000
18    16000
19    15000
Name: deposit, dtype: int64

In [45]:
df[df["deposit"] < 2000]   #행렬곱의 개념


Out[45]:
address1 address2 address3 agent_address1 agent_comment agent_email agent_local1 agent_local2 agent_mobile agent_name ... title updated_at user_email user_has_no_penalty user_has_penalty user_mobile user_name user_no user_phone view_count
2 서울시 관악구 신림동 1417-31 None 서울특별시 관악구 신림로 68길 29(신림동) goodhouse427@naver.com 서울시 관악구 0507-1280-3054 365공인중개사(유미선) ... ★가격대비 대만족 원룸 채광짱 구조짱~ 3개월 전 goodhouse427@naver.com True False 0507-1280-3054 대표공인중개사(유미선) 247417 0507-1280-3054 250
5 서울시 관악구 봉천동 933-26 None 서울특별시 관악구 봉천동 933-20 nadoyo2@naver.com 서울시 관악구 0507-1281-1580 21세기공인중개사(강병국) ... 역세권 엄청싸게나온 풀옵션 지상 방1 3개월 전 boktj1002@naver.com True False 0507-1281-0303 중개보조원(복소경) 1434787 0507-1281-0303 389
9 서울시 관악구 신림동 1629-54 None 서울특별시 관악구 신원로 26 (신림동) choyu00@nate.com 서울시 관악구 0507-1280-8154 발품공인중개사(조종현) ... 깔끄미 신축2룸 소개합니다^^ 3개월 전 choyu00@nate.com True False 0507-1280-8410 중개보조원(소재현) 14007 0507-1280-8410 314
11 서울시 구로구 구로3동 1126-36 None 서울특별시 구로구 구로동 1126-37 chk13189@naver.com 서울시 구로구 0507-1280-0488 수공인중개사(조혜경) ... ☀이벤트☀ 건물주가 미쳤어요 ~_~ 클릭!클릭! 3개월 전 chk13189@naver.com True False 0507-1280-0488 대표공인중개사(조혜경) 128135 0507-1280-0488 315
13 서울시 동작구 상도동 303-13 None 서울특별시 동작구 보라매로11길 3, 1층 yohousing@naver.com 서울시 동작구 0507-1281-1050 스타공인중개사(한상호) ... oOo깨끗한데 젤~~~싸요!!oOo 2개월 전 taegi76@naver.com True False 0507-1281-0028 중개보조원(김진택) 1399779 0507-1281-0028 235
14 서울시 관악구 봉천동 1605-25 None 서울특별시 관악구 봉천동 1598-23 1층 minho012@naver.com 서울시 관악구 0108-5536-4491 샛별공인중개사(이덕순) ... A급 반지하 3개월 전 minho012@naver.com True False 0108-5536-4491 대표공인중개사(이덕순) 1086355 0108-5536-4491 190

6 rows × 73 columns


In [46]:
matched_df = df[df["deposit"] < 2000][df["rent"] < 50]


C:\Anaconda3\lib\site-packages\ipykernel\__main__.py:1: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  if __name__ == '__main__':

In [49]:
matched_df.deposit


Out[49]:
2      300
5      300
11     300
13     500
14    1000
Name: deposit, dtype: int64

In [53]:
for index, column in enumerate(df):
    print(column)


address1
address2
address3
agent_address1
agent_comment
agent_email
agent_local1
agent_local2
agent_mobile
agent_name
agent_phone
bjd_code
bonbun_code
bubun_code
building
building_type
contract
deposit
description
description_og
elevator
floor
floor_all
id
images
images_count
images_thumbnail
is_deposit_only
is_direct
is_owner
is_premium
is_premium2
is_realestate
is_room
is_status_close
is_status_open
is_type_room
is_zzim
loan_text
local1
local2
local3
manage_cost
manage_cost_inc
movein_date
near_subways
options
original_user_phone
parking
pets_text
profile_url
random_location
read_updated_at
rent
room_direction_text
room_gubun_code
room_type
secret_memo
size
size_contract
size_m2
size_m2_contract
status
title
updated_at
user_email
user_has_no_penalty
user_has_penalty
user_mobile
user_name
user_no
user_phone
view_count

In [55]:
for i in len(df):   #보통은 이걸로 쓴다.


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-55-6d57d6f2dec2> in <module>()
----> 1 for i in len(df):
      2     print(i)

TypeError: 'int' object is not iterable

In [ ]: